package main

import (
	"fabric-test3/application/blockchain"
	"fabric-test3/application/controller"
	"github.com/gin-gonic/gin"
	"net/http"
)

func setupRouter() *gin.Engine {
	router := gin.Default()

	router.Use(controller.CORS)
	router.Use(controller.FixVueRouter)

	router.POST("/createCompany/", controller.CreateCompany)
	router.POST("/newTransaction/", controller.NewTransaction)

	router.GET("/getCompany/", controller.GetCompany)
	router.GET("/getTransactions/", controller.GetTransactions)
	router.GET("/getTransactionHistory/", controller.GetTransactionHistory)

	router.StaticFS("./web/", http.Dir("./public/"))

	return router
}

func main()  {
	blockchain.Init()
	router := setupRouter()
	err := router.Run()
	if err != nil {
		panic(err)
	}
}